//
//  MCMyCollectApi.swift
//  MCBodyBuildingPro
//
//  Created by Renlvshijie on 2023/5/24.
//

import Foundation
import Moya


enum MCMyCollectApi {
    //动作
    case fitnessList(current:Int?)
    //器械
    case myInstrumentList(current:Int?)
    //饮食
    case myDietHealthList(current:Int?)
}

extension MCMyCollectApi:TargetType {
    
    var baseURL: URL {
        return URL.init(string: Moya_baseURL)!
    }
    
    var path: String {
        switch self {
        case .fitnessList:
            return "api/app/collect/getCollectActionPage"
        case .myInstrumentList:
            return "api/app/collect/getCollectInstrumentPage"
        case .myDietHealthList:
            return "api/app/collect/getCollectDietPage"
        }
    }
    var method:Moya.Method {
        switch self {
        case .fitnessList,.myInstrumentList,.myDietHealthList:
            return .get
        }
    }
    
    var sampleData: Data {
        return Data()
    }
    
    
    var task: Task {
        switch self {
        case let .fitnessList(current):
            return .requestParameters(parameters: ["current":current ?? 1,"size":20], encoding: URLEncoding.default)
        case let .myInstrumentList(current):
            return .requestParameters(parameters: ["current":current ?? 1,"size":20], encoding: URLEncoding.default)
        case let .myDietHealthList(current):
            return .requestParameters(parameters: ["current":current ?? 1,"size":20], encoding: URLEncoding.default)
        }
    }
    
    var headers: [String : String]? {
        
        let tokenName:String = UserDefaults.standard.string(forKey: "LoginName") ?? ""
        let tokenValue:String = UserDefaults.standard.string(forKey: "LoginToken") ?? ""
        
        return [tokenName:tokenValue]
    }
    
    
}
